package shop.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import shop.IService;
import shop.model.Brand;
import shop.model.Product;

import java.io.Serializable;
import java.util.List;

@Controller
public class ProductController implements Serializable {
    @Autowired
    private IService<Product> productService;
    @Autowired
    private IService<Brand> brandService;

    private List<Product> products;
    private List<Brand> brands;
    private List<Product> filteredProducts;
    private Product selectedProduct;


    public List<Product> getProducts() {
        products = productService.readAll();
        return products;
    }

    public void setProducts(List<Product> products) {
        this.products = products;
    }

    public List<Brand> getBrands() {
        brands = brandService.readAll();
        return brands;
    }

    public void setBrands(List<Brand> brands) {
        this.brands = brands;
    }

    public List<Product> getFilteredProducts() {
        return filteredProducts;
    }

    public void setFilteredProducts(List<Product> filteredProducts) {
        this.filteredProducts = filteredProducts;
    }

    public Product getSelectedProduct() {
        return selectedProduct;
    }

    public void setSelectedProduct(Product selectedProduct) {
        this.selectedProduct = selectedProduct;
    }
}
